<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:hr="http://java.sun.com/jsf/composite/autocomplete">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">
                <h:form >
                    <p:panel >
                        <f:facet name="header" >
                            <h:outputLabel value="Employee Salary Payment To Bank " />
                        </f:facet>
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="Salary Cycle"/>
                            <p:selectOneMenu value="#{hrReportController.reportKeyWord.salaryCycle}" 
                                             var="t">
                                <f:selectItems value="#{salaryCycleController.salaryCycles}" 
                                               var="theme" 
                                               itemLabel="#{theme.name}" 
                                               itemValue="#{theme}" ></f:selectItems>

                                <p:column style="width:10%" headerText="Name">
                                    <h:outputText value="#{t.name}" />
                                </p:column>

                                <p:column headerText="Year">
                                    <h:outputText value="#{t.salaryYear}" />
                                </p:column>
                                <p:column headerText="Month">
                                    <h:outputText value="#{t.salaryMonth}" />
                                </p:column>
                            </p:selectOneMenu>
                            <h:outputLabel value="Institution : "/>
                            <hr:institution value="#{hrReportController.reportKeyWord.institution}"/>
                            <h:outputLabel value="Department : "/>
                            <hr:department value="#{hrReportController.reportKeyWord.department}"/>
                            <h:outputLabel value="Employee : "/>
                            <hr:completeStaff value="#{hrReportController.reportKeyWord.staff}"/>
                            <h:outputLabel value="Staff Category : "/>
                            <hr:completeStaffCategory value="#{hrReportController.reportKeyWord.staffCategory}"/>
                            <h:outputLabel value="Staff Designation : "/>
                            <hr:completeDesignation value="#{hrReportController.reportKeyWord.designation}"/>
                            <h:outputLabel value="Staff Roster : "/>
                            <hr:completeRoster value="#{hrReportController.reportKeyWord.roster}"/>
                            <h:outputLabel value="Branch(Bank) : "/>
                            <hr:completeBank_Branch value="#{hrReportController.reportKeyWord.bank}"/>
                            <h:outputLabel value="Bank : "/>
                            <hr:completeBank value="#{hrReportController.reportKeyWord.institutionBank}"/>
                            <h:outputLabel value="Employee Status : "/>
                            <p:selectOneMenu value="#{hrReportController.reportKeyWord.employeeStatus}" >
                                <f:selectItem itemLabel="Please select Employee Status"/>
                                <f:selectItems value="#{staffController.employeeStatuses}"/>
                            </p:selectOneMenu>
                            <h:outputLabel value="Show Blocked"/>
                            <p:selectBooleanCheckbox value="#{hrReportController.blocked}"/>
                            <h:outputLabel value="Show Hold"/>
                            <p:selectBooleanCheckbox value="#{hrReportController.hold}"/>
                        </h:panelGrid>

                        <p:commandButton ajax="false" value="Process Net Salary" action="#{hrReportController.createStaffSalaryNetSalary()}"/>
                        <p:commandButton ajax="false" value="Process OT Payment" action="#{hrReportController.createStaffSalaryOtPayment()}"/>
                        <p:commandButton ajax="false" value="Process Net And OT Payment" action="#{hrReportController.createStaffSalaryNetAndOtPayment()}"/>

                        <p:inputText value="#{hrReportController.chequeNo}" id="chq"/>
                        <p:watermark for="chq" value="Cheque Number"/>
                        <p:commandButton ajax="false" value="Update" action="#{hrReportController.update()}"/>

                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1" fileName="hr_report_staff_salary_payment_bank"  />
                        </p:commandButton>
                        <p:commandButton value="Print" ajax="false" action="#" >
                            <p:printer target="gpBillPreview" ></p:printer>
                        </p:commandButton>
                        <p:panel id="gpBillPreview"  styleClass="noBorder summeryBorder" >                     
                            <p:dataTable id="tb1" value="#{hrReportController.staffSalarys}" var="ss"  editable="true" rowStyleClass="#{ss.hold ? 'greenText': ss.blocked ? 'redText' :''}">
                                <f:facet name="header" >

                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.institution ne null}" >
                                        <h:outputLabel value="#{hrReportController.reportKeyWord.institution.name}" />
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.department ne null}" >
                                        <h:outputLabel value="Department : #{hrReportController.reportKeyWord.department.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.staff ne null}" >
                                        <h:outputLabel value="Staff : #{hrReportController.reportKeyWord.staff.person.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.institutionBank ne null}" >
                                        <h:outputLabel value="Bank : #{hrReportController.reportKeyWord.institutionBank.name}" />
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.roster ne null}" >
                                        <h:outputLabel value="Roster : #{hrReportController.reportKeyWord.roster.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:outputLabel value="Salary Range : #{hrReportController.reportKeyWord.salaryCycle.name}"/>
                                    <br/><br/>
                                    <h:outputLabel value="Cheque No :................................."/>
                                </f:facet>
                                <p:ajax event="rowEdit" listener="#{hrReportController.onEdit}" />  
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputLabel value="EMP No"/>
                                    </f:facet>

                                    <p:outputLabel value="#{ss.staff.code}" style="float: right;">
                                    </p:outputLabel>
                                </p:column>

                                <p:column style="width:6%"  exportable="false" styleClass="noPrintButton">  
                                    <p:rowEditor />  
                                </p:column>

                                <p:column rendered="#{!hrReportController.hold}" >
                                    <f:facet name="header">

                                        <h:outputLabel value="Emp Name"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staff.person.nameWithTitle}" rendered="#{(sessionController.loggedPreference.applicationInstitution eq 'Ruhuna' and !ss.hold)
                                                            or sessionController.loggedPreference.applicationInstitution ne 'Ruhuna'}">
                                    </p:outputLabel>
                                    <p:outputLabel value="Ruhunu Hospital (Pvt) Ltd" rendered="#{(sessionController.loggedPreference.applicationInstitution eq 'Ruhuna' and ss.hold) 
                                                                                                 or(sessionController.loggedPreference.applicationInstitution eq 'Ruhuna' and ss.blocked)}">
                                    </p:outputLabel>
                                </p:column>
                                <p:column rendered="#{hrReportController.hold}" >
                                    <f:facet name="header">

                                        <h:outputLabel value="Emp Name"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staff.person.nameWithTitle}">
                                    </p:outputLabel>
                                </p:column>

                                <p:column rendered="#{hrReportController.reportKeyWord.institutionBank eq null}" >
                                    <f:facet name="header">
                                        <h:outputLabel value="Bank"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.bankBranch.institution.name}">
                                    </p:outputLabel>
                                </p:column>

                                <p:column styleClass="noPrintButton">
                                    <f:facet name="header">
                                        <h:outputLabel value="Bank Branch"/>
                                    </f:facet>
                                    <p:cellEditor>  
                                        <f:facet name="output">
                                            <p:outputLabel value="#{ss.bankBranch.name}"/>
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:autoComplete disabled="#{!ss.blocked and !ss.hold}" id="pgbank" completeMethod="#{institutionController.completeBankBranch}" 
                                                            var="dept"
                                                            itemLabel="#{dept.name}"
                                                            itemValue="#{dept}"
                                                            forceSelection="true" 
                                                            value="#{ss.bankBranch}" 
                                                            converter="institutionConverter" >
                                                <p:column headerText="Name">
                                                    <h:outputLabel value="#{dept.name}"/>
                                                </p:column>
                                                <p:column headerText="Banck">
                                                    <h:outputLabel value="#{dept.institution.name}"/>
                                                </p:column>
                                                <p:column headerText="Code">
                                                    <h:outputLabel value="#{dept.institutionCode}"/>
                                                </p:column>
                                            </p:autoComplete>
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column styleClass="noPrintButton" rendered="false">
                                    <f:facet name="header">
                                        <h:outputLabel value="cheque No"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.chequeNumberOverTime}/">
                                    </p:outputLabel>
                                    <p:outputLabel value="#{ss.chequeNumberSalary}/">
                                    </p:outputLabel>
                                    <p:outputLabel value="#{ss.chequeNumberSalaryAndOverTime}">
                                    </p:outputLabel>
                                </p:column>

                                <p:column rendered="#{!hrReportController.hold}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Account No"/>
                                    </f:facet>
                                    <p:cellEditor>  
                                        <f:facet name="output">
                                            <p:outputLabel value="#{ss.accountNo}"  />
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:inputText id="txtin" value="#{ss.accountNo}" disabled="#{!ss.blocked and !ss.hold}" styleClass="shortinput"/>
                                        </f:facet>
                                    </p:cellEditor>

                                </p:column>
                                <p:column rendered="#{hrReportController.hold}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Account No"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.staff.accountNo}"  />
                                </p:column>

                                <p:column headerText="Block" styleClass="noPrintButton">
                                    <p:cellEditor>  
                                        <f:facet name="output">
                                            <h:outputLabel value="Blocked" rendered="#{ss.blocked}">
                                            </h:outputLabel>
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:selectBooleanCheckbox id="boBlock" value="#{ss.blocked}" >
                                                <f:ajax event="change"  execute="@this" render="@this txtin boHold pgbank" listener="#{hrReportController.listnerBlock(ss)}"/>
                                            </p:selectBooleanCheckbox>  
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>
                                <p:column headerText="Hold" styleClass="noPrintButton">
                                    <p:cellEditor>  
                                        <f:facet name="output">
                                            <h:outputLabel value="Hold" rendered="#{ss.hold}">
                                            </h:outputLabel>
                                        </f:facet>
                                        <f:facet name="input">
                                            <p:selectBooleanCheckbox id="boHold" value="#{ss.hold}" >
                                                <f:ajax event="change" execute="@this" render="@this txtin boBlock pgbank" listener="#{hrReportController.listnerHold(ss)}"/>
                                            </p:selectBooleanCheckbox>   
                                        </f:facet>
                                    </p:cellEditor>
                                </p:column>

                                <p:column rendered="#{hrReportController.netSalary}" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Salary"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.transNetSalry}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </p:outputLabel>
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{hrReportController.totalTransNetSalary}" style="text-align: right;" styleClass="noPrintButton">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>                                    </f:facet>
                                </p:column>

                                <p:column rendered="#{hrReportController.otPayment}" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Over Time"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.transExtraDutyValue+ss.overTimeValue}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </p:outputLabel>
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{hrReportController.totalOverTime}" style="text-align: right;" styleClass="noPrintButton">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>  
                                    </f:facet>
                                </p:column>

                                <p:column rendered="#{hrReportController.otPayment and hrReportController.netSalary}" style="text-align: right;">
                                    <f:facet name="header">
                                        <h:outputLabel value="Total"/>
                                    </f:facet>
                                    <p:outputLabel value="#{ss.transExtraDutyValue+ss.overTimeValue+ss.transNetSalry}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </p:outputLabel>
                                    <f:facet name="footer">
                                        <h:outputLabel value="#{hrReportController.totalOverTime+hrReportController.totalTransNetSalary}" style="text-align: right;">
                                            <f:convertNumber pattern="#,##0.00"/>
                                        </h:outputLabel>  
                                    </f:facet>
                                </p:column>
                                
                                <p:column rendered="#{hrReportController.hold}">
                                    <f:facet name="header">
                                        <h:outputLabel value="Signature"/>
                                    </f:facet>
                                    <p:outputLabel value="........................"  />
                                </p:column>

                                <p:column rendered="false" >
                                    <p:commandButton process="@this" 
                                                     ajax="false"
                                                     value="Update"  
                                                     actionListener="#{hrReportController.onEditBlockedUpdate(ss)}" 
                                                     onclick="onSubmitButton();">                              
                                    </p:commandButton>                          
                                </p:column>

                                <f:facet name="footer">
                                    <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                    <p:outputLabel value="Print At : " />
                                    <p:outputLabel value="#{commonController.currentDateTime}" >
                                        <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                    </p:outputLabel>
                                </f:facet>
                            </p:dataTable>
                        </p:panel>


                    </p:panel>

                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
